using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class controls_usrEmail : System.Web.UI.UserControl
{
    protected string strEmail = "Select";
    protected string strValidatinoGroup = "";
    protected string strRequireErrorMessage = "Require Email Address";
    protected string strInvalidErrorMessage = "Invalid Email Address";
    protected bool bEnabled = true;

    protected void Page_Load(object sender, EventArgs e)
    {
        rfvEmail.Validate();
    }

    public bool IsEnabled
    {
        get { return bEnabled; }
        set
        {
            bEnabled = value;
            SetEnabled();
        }
    }

    public string Email
    {
        get { return strEmail; }
        set { strEmail = value; }
    }

    public string ValidationGroup
    {
        get { return strValidatinoGroup; }
        set { strValidatinoGroup = value; }
    }

    public string RequireErrorMessage
    {
        get { return strRequireErrorMessage; }
        set { strRequireErrorMessage = value; }
    }

    public string InvalidErrorMessage
    {
        get { return strInvalidErrorMessage; }
        set { strInvalidErrorMessage = value; }
    }

    private void SetEnabled()
    {
        //ddlEmail.SelectedIndex = 0;
        txtEmailAddress.Enabled = bEnabled;
        rfvEmail.Enabled = bEnabled;
        revEmail.Enabled = bEnabled;
    }

    protected override void OnPreRender(EventArgs e)
    {
        SetEnabled();

        if (strValidatinoGroup != null)
        {
            if (strValidatinoGroup != string.Empty)
            {
                rfvEmail.ValidationGroup = strValidatinoGroup;
                revEmail.ValidationGroup = strValidatinoGroup;
            }
        }

        if (strRequireErrorMessage != string.Empty)
        {
            rfvEmail.ErrorMessage = strRequireErrorMessage;
        }

        if (strInvalidErrorMessage != string.Empty)
        {
            revEmail.ErrorMessage = strInvalidErrorMessage;
        }

    }

    public string GetEmail()
    {
        strEmail = txtEmailAddress.Text;
        return strEmail;
    }
}
